﻿//赋值存货列表
function getInvenClass() {
    var type = location.search;
    if (type!="") {
        $("#synchronous").css('display','none');
    }
    var cCode = $("#cCode").val();
    var cName = $("#cName").val();
    layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            , layer = layui.layer //弹层
            , table = layui.table //表格
            , carousel = layui.carousel //轮播
            , upload = layui.upload //上传
            , element = layui.element //元素操作
            , slider = layui.slider //滑块


        //给table赋值
        table.render({
            elem: '#InvenClassList'
            ,id:'InvenClassList'
            , height: 380
            //, width: 1030
            , url: '../Basis/getInvenClassList?cCode='+cCode+'&cName='+cName+'' //数据接口
            , title: '存货类别表'
            , page: true //开启分页
            , even: true
            , limits: [20, 50, 80, 100]
            , toolbar: true //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            , defaultToolbar: ['print', 'exports']
            , cols: [[ //表头
                { type: 'checkbox', fixed: 'left' }
                , { field: 'cCode', title: '类别编号', width: 150, sort: true, fixed: 'left' }
                , { field: 'cName', title: '类别名称', width: 150 }
                , { field: 'accCode', title: '所属账套', width: 110 }
                , { field: 'isAccName', title: '同步数据', width: 110, sort: true }
                , { field: 'createTime', title: '创建时间', width: 180 }
                , { field: 'createUser', title: '创建人员', width: 150 }
            ]]
        });

        //监听复选框选中
        table.on('checkbox(InvenClassList)', function (obj) {
            var checkStatus = table.checkStatus('InvenClassList');
            var data = checkStatus.data;
            var str = "";
            for (var i = 0; i < data.length; i++) {
                if (str=="") {
                    str = data[i].cCode;
                } else {
                    str += ","+data[i].cCode;
                }
            }
            //给父页面赋值
            $("#typeCode", parent.document).val(str);
            $("#InvenCode", parent.document).val("");
            window.parent.InvenClassInputTextChange();
        });
    });
}